package entity;

import org.hibernate.annotations.*;
import org.hibernate.annotations.Cache;

import javax.persistence.*;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;

/**
 * Created by xuweijie on 2017/4/20.
 */
@Entity
@Table(name = "cro_role_menus")
@DynamicInsert(true)
//@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class CroRoleMenus implements Serializable{

    private String id;
    private CroRole croRole;
    private CroMenus croMenus;



    @Id
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @OneToOne(cascade ={CascadeType.REFRESH},fetch =FetchType.EAGER)
    @JoinColumn(name ="roleId",referencedColumnName = "id")
    public CroRole getCroRole() {
        return croRole;
    }

    public void setCroRole(CroRole croRole) {
        this.croRole = croRole;
    }

    @OneToOne(cascade ={CascadeType.REFRESH},fetch =FetchType.EAGER)
    @JoinColumn(name ="menuId",referencedColumnName = "id")
    public CroMenus getCroMenus() {
        return croMenus;
    }

    public void setCroMenus(CroMenus croMenus) {
        this.croMenus = croMenus;
    }
}
